﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/select2/select2.min.js"></script>
    <link href="~/Content/select2/select2.min.css" rel="stylesheet" />
    <script src="~/Content/Scripts/System/Common.js"></script>
</head>
<body>
    <span style="margin-top:15px;margin-left:15px">
        <xblock>
            <button class="layui-btn" onclick="submitForm()"><i class="layui-icon"></i>保存</button>
            <button class="layui-btn" onclick="closeWin()"><i class="layui-icon">&#x1006;</i>取消</button>
        </xblock>
       </span>
        <div style="margin: 20px; border: 1px solid #dbdbdb;padding:15px">

            <form>

                <div class="layui-form-item">

                    <label class="layui-form-label">
                        当前密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="oldPwd" name="oldPwd" required="" autocomplete="off" class="layui-input">

                    </div>

                </div>

                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        修改密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" name="newPwd" class="layui-input" lay-verify="required"
                               autocomplete="off" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" name="surePwd" class="layui-input" lay-verify="required"
                               autocomplete="off" />
                    </div>
                </div>

            </form>
        </div>
</body>
</html>
<script>

    /** 保存权限信息 **/
    function submitForm() {
        try {
            var newpwd = $('[name="newPwd"]').val();
            var surepwd = $('[name="surePwd"]').val();
            var oldpwd = $('[name="oldPwd"]').val();
            if (newpwd == "" || surepwd == "" || oldpwd == "") {
                layer.msg("所有项不能为空");
                return;
            }
         
            if(newpwd!=surepwd){
                layer.msg("两次输入密码不一致");
                return;
            }
            $.ajax({
                url: "../System/ChanagePWD",
                data: { newPwd: newpwd, oldPwd: oldpwd },
                dataType: "json",
                type: "POST",
                success: function (data) {
                    if (data.Result) {
                        layer.alert("密码修改成功", { icon: 6 }, function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(data.Message);
                    }
                }
            });
        } catch (e) {
            alert(e.message);
            window.location = "/Error/Error";
        }
    }
</script>
